﻿Imports kplusEntity.KPLUS.Entity
Imports System.Data.OracleClient

Namespace KPLUS.Data
    Public Class DPBI

        Public Function fListarPBI(ByVal con As OracleConnection) As List(Of EPBI)
            Dim lstEPBI As New List(Of EPBI)

            Dim objCmd As New OracleCommand()
            objCmd.Connection = con
            objCmd.CommandText = "ODS.PKG_PRM_MANTENIMIENTO.PR_P_SEL_PBI"
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.Parameters.Add("pocur_PBI", OracleType.Cursor).Direction = ParameterDirection.Output

            Dim objReader As OracleDataReader = objCmd.ExecuteReader()

            Dim pos_NumAnhio As Integer = objReader.GetOrdinal("NumAnhio")
            Dim pos_NumVersion As Integer = objReader.GetOrdinal("NumVersion")
            Dim pos_MtoPBIAnual As Integer = objReader.GetOrdinal("MtoPBIAnual")
            Dim pos_CodUsrRegistro As Integer = objReader.GetOrdinal("CodUsrRegistro")
            Dim pos_FlgActivo As Integer = objReader.GetOrdinal("FlgActivo")
            Dim pos_FecRegistro As Integer = objReader.GetOrdinal("FecRegistro")
            Dim pos_TipoOperacion As Integer = objReader.GetOrdinal("TipOperacion")
            Dim pos_FecActualizacionTabla As Integer = objReader.GetOrdinal("FecActualizacionTabla")

            Dim objEPBI As EPBI
            Do While objReader.Read
                objEPBI = New EPBI
                With objEPBI
                    .NumAnhio = objReader.GetOracleNumber(pos_NumAnhio)
                    .NumVersion = objReader.GetOracleNumber(pos_NumVersion)
                    .MtoPBIAnual = objReader.GetOracleNumber(pos_MtoPBIAnual)
                    .CodUsrRegistro = objReader.GetOracleString(pos_CodUsrRegistro)
                    .FlgActivo = objReader.GetOracleString(pos_FlgActivo)
                    .FecRegistro = objReader.GetOracleDateTime(pos_FecRegistro)
                    .TipoOperacion = objReader.GetOracleString(pos_TipoOperacion)
                    .FecActualizacionTabla = objReader.GetOracleDateTime(pos_FecActualizacionTabla)
                End With
                lstEPBI.Add(objEPBI)
            Loop

            objReader.Close()

            Return (lstEPBI)
        End Function
    End Class
End Namespace

